﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	搜索页面
'	2012.4.5

Sub main
	Dim keyword,id,body_,rs,sear,a,sql
	Dim PageSize,Count,page,pagecount,i,class_
	id=getN("id",1)
	keyword=getFilter("keyword","")
	hu.title = "网站搜索"
	body_ = checkMsg()'信息
	if keyword="" then
		body_ = body_ & "[div=nav]-" &hu.url("?aid=index", "首页") & "-网站搜索[/div]" & getSearchXml_() & "<br/>"
	else
		a=getN("a",0)
		sear=getN("sear",0)
		body_ = body_ & "[div=nav]-" & hu.url("?aid=index", "首页") & "-" &hu.url("search.asp", "搜索") &"-搜索结果[/div]"
		If a=0 Then
			if sear=1 then
				sql = "select id,title from 74hu_article where classid<>0 and title like '%" & keyword & "%' order by id desc"
			elseif sear=2 then
				sql = "select id,title from 74hu_article where classid<>0 and InStr(1,test,'"&Keyword&"',0)>0 order by id desc"
			else
				sql = "select id,title from 74hu_article where classid<>0 and InStr(1,test,'"&Keyword&"',0)>0 or title like '%" & keyword & "%' order by id desc"
			end if
			Set rs = Server.CreateObject("ADODB.Recordset")
			rs.open sql, hu.db, 1, 1
			If Not rs.eof Then
				count = rs.recordcount
				PageSize=10
				page=getN("page",0)
				if page<=0 then page=1
				pagecount=(count+pagesize-1)\pagesize
				if page>pagecount then page=pagecount
				rs.move(pagesize*(page-1))
				body_ = body_ & "共:"&count&"篇相关文章<br/>"
				For i=1 To PageSize
					If rs.eof Then Exit For
					If i mod 2 = 0 Then
						class_="even"
					Else
						class_="odd"
					End If
					body_ = body_ & "[div="&class_&"]"&hu.url("article.asp?id="&rs("id"),i+(page-1)*PageSize&"."&nowml(rs("title")))&"[/div]"
					rs.moveNext
				Next
				body_ = body_ & showPage("search.asp", "keyword:"&keyword&",sear:"&sear, page, pagecount)&""
			Else
				body_ = body_ & "没有符合条件的文章<br/>"
			end if
		Else
			if sear=1 then
				sql = "select id,title from 74hu_topic where title like '%" & keyword & "%' order by id desc"
			elseif sear=2 then
				sql = "select id,title from 74hu_topic where InStr(1,content,'"&Keyword&"',0)>0 order by id desc"
			else
				sql = "select id,title from 74hu_topic where InStr(1,content,'"&Keyword&"',0)>0 or title like '%" & keyword & "%' order by id desc"
			end if
			Set rs = Server.CreateObject("ADODB.Recordset")
			rs.open sql, hu.db, 1, 1
			If Not rs.eof Then
				count = rs.recordcount
				PageSize=10
				page=getN("page",0)
				if page<=0 then page=1
				pagecount=(count+pagesize-1)\pagesize
				if page>pagecount then page=pagecount
				rs.move(pagesize*(page-1))
				body_ = body_ & "共:"&count&"篇相关帖子<br/>"
				For i=1 To PageSize
					If rs.eof Then Exit For
					If i mod 2 = 0 Then
						class_="even"
					Else
						class_="odd"
					End If
					body_ = body_ & "[div="&class_&"]"&hu.url("bbs_posts.asp?id="&rs("id"), i+(page-1)*PageSize&"."&nowml(rs("title")))&"[/div]"
					rs.moveNext
				Next
				body_ = body_ & showPage("search.asp", "keyword:"&keyword&",a:1,sear:"&sear, page, pagecount)&""
			Else
				body_ = body_ & "没有符合条件的帖子<br/>"
			end if
		End If
		set rs=nothing
		body_ = body_ & hu.url("search.asp", "返回搜索中心")&"<br/>"
	end if
	hu.body = comUbb(body_)
End Sub


Function getSearchXml_()
	If hu_style Then
		getSearchXml_ = "※文章搜索：<br/>"&_
		 "<form name=""txtsearch"" action="""&http_path&"search.asp"" method=""post"">"&_
		 "<input type=""text"" name=""keyword"" value=""""/><br/>"&_
		 "<select name=""sear""><option value=""1"">标题</option><option value=""2"">内容</option><option value=""0"">全文</option></select>"&_
		 "<input type=""hidden"" name="""&bbsSid&""" value="""&sid&""" />"&_
		 "&nbsp;<input type=""submit"" name=""submit"" value=""开始搜索"" /></form><br/>"&_
		 "<br/>※论坛搜索：<br/>"&_
		 "<form name=""bbssearch"" action="""&http_path&"search.asp"" method=""post"">"&_
		 "<input type=""text"" name=""keyword"" value=""""/><br/>"&_
		 "<select name=""sear""><option value=""1"">标题</option><option value=""2"">内容</option><option value=""0"">全文</option></select>"&_
		 "<input type=""hidden"" name=""a"" value=""1"" />"&_
		 "<input type=""hidden"" name="""&bbsSid&""" value="""&sid&""" />"&_
		 "&nbsp;<input  type=""submit"" name=""submit"" value=""开始搜索"" /></form>"
	Else
		getSearchXml_ =  "<input type=""text"" name=""keyword"&Time_r&""" value=""美女"" title=""请输入关键词""/><br/>"&_
		 "搜<anchor>文章<go href="""&http_path&"search.asp"" method=""post""><postfield name="""&bbsSid&""" value="""&sid&"""/>"&_
		 "<postfield name=""keyword"" value=""$(keyword"&Time_r&")""/><postfield name=""sear"" value=""0""/></go></anchor>"&_
		 ".<anchor>标题<go href="""&http_path&"search.asp"" method=""post""><postfield name="""&bbsSid&""" value="""&sid&"""/>"&_
		 "<postfield name=""keyword"" value=""$(keyword"&Time_r&")""/><postfield name=""sear"" value=""1""/></go></anchor>"&_
		 ".<anchor>内容<go href="""&http_path&"search.asp"" method=""post""><postfield name="""&bbsSid&""" value="""&sid&"""/>"&_
		 "<postfield name=""keyword"" value=""$(keyword"&Time_r&")""/><postfield name=""sear"" value=""2""/></go></anchor><br/>"&_
		 "搜<anchor>帖子<go href="""&http_path&"search.asp?a=1"" method=""post""><postfield name="""&bbsSid&""" value="""&sid&"""/>"&_
		 "<postfield name=""keyword"" value=""$(keyword"&Time_r&")""/><postfield name=""sear"" value=""0""/></go></anchor>"&_
		 ".<anchor>标题<go href="""&http_path&"search.asp?a=1"" method=""post""><postfield name="""&bbsSid&""" value="""&sid&"""/>"&_
		 "<postfield name=""keyword"" value=""$(keyword"&Time_r&")""/><postfield name=""sear"" value=""1""/></go></anchor>"&_
		 ".<anchor>内容<go href="""&http_path&"search.asp?a=1"" method=""post""><postfield name="""&bbsSid&""" value="""&sid&"""/>"&_
		 "<postfield name=""keyword"" value=""$(keyword"&Time_r&")""/><postfield name=""sear"" value=""2""/></go></anchor>"
	End If
End Function

%>